<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:55:"E:\WWW\waimai/app/admin/shop\view\shop_order\index.html";i:1501487074;s:53:"E:\WWW\waimai/app/admin/index\view\template\base.html";i:1495522842;}*/ ?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link href="__STATIC__/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <!--图标字体元件库-->
    <link rel="stylesheet" href="__STATIC__/plugins/font-awesome4.5.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="__STATIC__/admin/css/AdminLTE.min.css">
    <link rel="stylesheet" href="__STATIC__/admin/css/jquery.datetimepicker.css">
    <link rel="stylesheet" href="__STATIC__/admin/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="__STATIC__/plugins/validform/5.3.2/css/Validateform_v5.3.2.css">

    <link rel="stylesheet" href="__STATIC__/plugins/bootstrap-table/bootstrap-table.min.css">
    <link rel="stylesheet" href="__STATIC__/plugins/iCheck/polaris/polaris.css">
    <link rel="stylesheet" href="__STATIC__/plugins/iCheck/futurico/futurico.css">
    <link rel="stylesheet" href="__STATIC__/plugins/iCheck/line/_all.css">
    <link rel="stylesheet" href="__STATIC__/plugins/iCheck/square/_all.css">
    <link rel="stylesheet" href="__STATIC__/plugins/iCheck/flat/_all.css">
    <link rel="stylesheet" href="__STATIC__/plugins/iCheck/minimal/_all.css">
    
<style>
    #table td {
        border-bottom: 1px solid #ddd;
    }

    .list_goods {
        list-style: none;
        margin: 0 0 5px;
        padding: 5px 0 0;
        font-size: 12px;
        width: 100%;
        height: 60px;
        box-sizing: content-box;
        border-top: 1px solid #ddd;
    }

    .list_goods:first-child {
        border-top: none;
    }

    .list_goods .img {
        float: left;
        width: 60px;
        height: 60px;
        text-align: center;
        line-height: 60px;
        margin-right: 15px;
        border: 1px solid #eee;
        box-sizing: border-box;
    }

    .list_goods .img img {
        max-width: 100%;
        max-height: 100%;
    }

    .list_goods .text {
        float: left;
        line-height: 25px;
        width: 300px;
    }

    .list_goods p {
        margin: 0;
    }

    .list_goods .price {
        float: left;
        line-height: 25px;
    }
</style>

<style>
    .cal{margin: 15px 15px 20px 15px}
    .info-box-icon{
        height: 57px;
        line-height: 57px;
    }
    .info-box{
        min-height: 58.5px;
        margin-bottom: 0;
        border: 1px solid #ccc;
    }
</style>


    <title><?php echo \think\Config::get('site.title'); ?></title>
    

    <script src="__STATIC__/plugins/jquery/jquery-3.0.0.min.js"></script>
    <script src="__STATIC__/plugins/bootstrap/js/bootstrap.min.js"></script>
    <script src="__STATIC__/admin/js/app.min.js"></script>
    <script src="__STATIC__/admin/extend/app.js"></script>

    <script src="__STATIC__/admin/extend/H-ui.admin.js"></script>
    <script src="__STATIC__/plugins/layer3.0.3/layer.js"></script>
    <script src="__STATIC__/plugins/validform/5.3.2/Validform_v5.3.2_min.js"></script>

    <script src="__STATIC__/plugins/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
    <script src="__STATIC__/plugins/bootstrap-table/bootstrap-table-zh-CN.js" type="text/javascript"></script>

    <script src="__STATIC__/plugins/iCheck/icheck.min.js"></script>
    <script>

        var admin_menu_data=<?php if(isset($admin_menu)): ?><?php echo $admin_menu; endif; ?>;
        $(function () {
            $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
                checkboxClass: 'icheckbox_minimal-blue',
                radioClass: 'iradio_minimal-blue'
            });
        })
    </script>

    
</head>
<body class="hold-transition skin-blue-light sidebar-mini">
    

<div class="cal">
    <div class="row">
        <!-- /.col -->
        <!-- /.col -->
        <div class="col-md-3 col-sm-3 col-xs-12">
            <div class="info-box">
                <span class="info-box-icon bg-yellow"><i class="fa fa-files-o"></i></span>

                <div class="info-box-content">
                    <span class="info-box-text">订单总量</span>
                    <span class="info-box-number"><?php echo $cal['count']; ?></span>
                </div>
                <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
        </div>
        <!-- /.col -->
        <div class="col-md-3 col-sm-3 col-xs-12">
            <div class="info-box">
                <span class="info-box-icon bg-red"><i class="fa fa-star-o"></i></span>

                <div class="info-box-content">
                    <span class="info-box-text">订单总额</span>
                    <span class="info-box-number"><?php echo $cal['sum']; ?></span>
                </div>
                <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
        </div>
        <!-- /.col -->
    </div>
</div>
<div class="row">

    <div class="col-xs-12">
        <div class="box-body">
            <div class="row">
                <div class="col-xs-3">
                    <div class="input-group col-xs-12">
                        <span class="input-group-addon">关键字</span>
                        <input type="text" class="form-control" id="keyword" placeholder="订单号、手机号、收货人相关信息"/>
                    </div>
                </div>

                <div class="col-xs-3">
                    <div class="input-group col-xs-12">
                        <span class="input-group-addon">订单时间</span>
                        <input class="form-control datetimepicker" type="text" name="begindate"
                               id="begindate" placeholder="起始日期"/>
                        <span class="input-group-addon" style="width:1em;">至</span>
                        <input class="form-control datetimepicker" type="text" name="enddate" id="enddate"
                               placeholder="截止日期"/>
                    </div>
                </div>

                <div class="col-xs-1">
                    <div class="input-group col-xs-12">
                        <select class="form-control select2" id="flag_status">
                            <option selected="selected" value="-1">订单状态</option>
                            <option value="0">未配送</option>
                            <option value="1">正在配送</option>
                            <option value="2">申请取消</option>
                            <option value="3">确定取消</option>
                            <option value="4">取消订单</option>
                            <option value="5">货到付款</option>
                            <option value="6">正在配送(货到付款)</option>
                            <option value="7">已收货</option>
                        </select>
                    </div>
                </div>
                <!--<div class="col-xs-1">-->
                    <!--<div class="input-group col-xs-12">-->
                        <!--<select class="form-control" id="sel_status">-->
                            <!--<option selected="selected" value="-1">支付状态</option>-->
                            <!--<option value="0">未支付</option>-->
                            <!--<option value="1">已支付</option>-->
                        <!--</select>-->
                    <!--</div>-->
                <!--</div>-->
                <div class="col-xs-1">
                    <div class="input-group col-xs-12">
                        <select class="form-control select2" id="flag_delivery">
                            <option selected="selected" value="-1">付款类型</option>
                            <option value="0">在线支付</option>
                            <option value="1">货到付款</option>
                        </select>
                    </div>
                </div>
                <div class="col-xs-1">
                    <button type="button" class="btn btn-primary" id="btn_search"><i
                            class="glyphicon glyphicon-search"></i> 搜索
                    </button>
                    <!--<button type="button" class="btn btn-default" id="btn_export"><i-->
                    <!--class="glyphicon glyphicon-export"></i> 导出Excel-->
                    <!--</button>-->
                </div>

            </div>
        </div>
    </div>

    <div class="col-xs-12">
        <div class="box">
            <div class="box-body">
                <table id="table"
                       data-toggle="table"
                       data-striped ="true"
                       data-query-params = "requestParam"
                       data-detail-formatter="detailFormatter"
                       data-detail-view="true"
                       data-side-pagination="server"
                       data-pagination="true"
                       data-id-field="id"
                       data-url="<?php echo url('ShopOrder/index_data'); ?>"
                >
                    <thead>
                    <tr>
                        <!--<th data-field="id">ID</th>-->
                        <th data-field="order_time" data-sortable="true">订单日期</th>
                        <th data-field="order_sn">订单号</th>
                        <th data-field="o_name" data-formatter="formatNick">收货人</th>
                        <th data-field="order_amount" data-formatter="formatPrice">订单金额</th>

                        <!--<th data-field="goods_quantity">商品总数量</th>-->
                        <!--<th data-field="discount_amount">优惠金额</th>-->
                        <!--<th data-field="flag_pay" data-formatter="formatPayStatus">支付状态</th>-->
                        <th data-field="flag_status" data-formatter="formatStatus">订单状态</th>
                        <th data-field="flag_delivery" data-formatter="formatDelivery">支付方式</th>
                        <th data-field="dname">配送员</th>
                        <th data-field="operate" data-formatter="formatOperate" data-events="operateEvents" >操作</th>
                    </tr>
                    </thead>
                </table>
            </div><!-- /.box-body -->
        </div><!-- /.box -->

    </div><!-- /.col -->
</div><!-- /.row -->

</body>
<script src="__STATIC__/admin/js/skins_control.js"></script>
<script src="__STATIC__/admin/js/jquery.datetimepicker.js"></script>

<script>
    var detail_data_url="<?php echo url('ShopOrder/detail'); ?>";
</script>
<script>
    $('.datetimepicker').datetimepicker({
        format: "Y-m-d",
        lang: 'ch',
        timepicker: false
    });
</script>
<script>

    $(function () {
        var $table=$('#table');

//        $table.on('load-success.bs.table', function () {
//            //展开所有折叠行
//            $table.bootstrapTable('expandAllRows');
//        })
    })

</script>
<script>
    // <editor-fold defaultstate="collapsed" desc="格式化url">
    function urlFormat(url) {
        if( url.indexOf('.html')){
            url=url.replace('.html','')
        }
        return url;
    }
    // </editor-fold>


    //搜索按钮事件
    $("#btn_search").on('click', function () {
        $('#table').bootstrapTable('refresh');
    })

    $("#sel_status").on('change', function () {
        $('#table').bootstrapTable('refresh');
    })

    $("#flag_delivery").on('change', function () {
        $('#table').bootstrapTable('refresh');
    })

    $("#flag_status").on('change', function () {
        $('#table').bootstrapTable('refresh');
    })


    var temp = {};
    function requestParam(params) {
        temp = {
            limit: params.limit, //页面大小
            offset: params.offset, //页码
            order: params.order,
            sort: params.sort,
            search: $("#keyword").val(),
            status: $("#sel_status").val(),
            flag_delivery:$("#flag_delivery").val(),
            flag_status:$("#flag_status").val(),
            begindate: $("#begindate").val(),
            enddate: $("#enddate").val()
        };
        return temp;
    }


    // <editor-fold defaultstate="collapsed" desc="添加">
    $('#add_btn').on('click',function () {
        layer_open('添加',add_data_url)
    });
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="操作按钮">
    function formatOperate(value,row,index){
        return [
            '<button class="btn btn-success btn-xs row_detail" href="javascript:void(0)">',
            '订单详情',
            '</button>&nbsp;',
        ].join('');
    }

    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="操作函数">
    window.operateEvents = {
        'click .row_detail': function (e, value, row, index) {
            layer_open('订单详情',urlFormat(detail_data_url)+"/id/"+row.id);
        },
    }

    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="状态格式化">
    function formatPayStatus(value) {
        switch(value){
            case 0:
                return '<i class="fa fa-minus-circle text-yellow" title="未支付">未支付</i>';break;
            case 1:
                return '<i class="fa fa-check-circle text-green" title="已支付">已支付</i>';break;
        }

    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="支付方式">
    function formatDelivery(value) {
        switch(value){
            case 0:
                return '<i class="fa text-yellow" title="在线支付">在线支付</i>';break;
            case 1:
                return '<i class="fa text-green" title="货到付款">货到付款</i>';break;
        }

    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="字段格式化">
    //格式下单用户
    function formatNick(value, e) {
        return e.o_name + '<br/>' + e.o_mobile;
    }
    //格式化价格
    function formatPrice(value) {
        return parseFloat(value).toFixed(2);
    }

    //格式化状态
    function formatStatus(value, e) {
        var status = value.value;
        var class_name = '';
        if (status == '2' || status == '6') {
            class_name = ' bg-green';
        }
        if (status == '4') {
            class_name = ' bg-red';
        }
        if (status == '0') {
            class_name = ' bg-yellow';
        }
        return '<span class="badge' + class_name + '">' + value.text + '</span>';
    }
// </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="订单商品列表">
    function detailFormatter(index, row) {

        var html = [];
        var arr = row.goods.split('###');
//        console.log(arr.length);
        var itemId="",count=0;
        var myArray=new Array();
        var item_o_sn=new Array();
        var count = 0;
        for (var i = 0; i < arr.length; i++) {
            var brr = arr[i].split('@@@');
            if(itemId !=brr[6] ){
                itemId =brr[6];
                item_o_sn[count] = brr[6];
                count ++;
            }
        }

        var html1="";
        for (var j = 0; j < item_o_sn.length; j++) {
            var html2="";
            html1='<div>'+item_o_sn[j]+'</div>';

            for (var k = 0; k < arr.length; k++) {
                var brr = arr[k].split('@@@');

                if(item_o_sn[j]==brr[6]){
                    html2=html2+'<ul class="list_goods">' +
                    '<li class="img"><img src="' + brr[1] + '"/></li>' +
                    '<li class="text"><p>' + brr[2] + '</p><p>' + parseFloat(brr[5]).toFixed(2) + '</p></li>' +
                    '<li class="price"><p>总价：' + parseFloat(brr[4]).toFixed(2) + '</p><p>数量：x' + brr[3] + '</p></li>' +
                    '</ul>'
                }
            }
            html1=html1+html2;
            html.push(html1);

        }

        return html.join('');
    }

    // </editor-fold>

</script>

</html>